/**
 *
 */
package com.edooschool.webpay.entity;

import org.apache.commons.lang3.StringUtils;

/**
 * @author downpour
 *
 */
public enum PayEvent {

    REQUEST("request", "支付请求"),

    PAID("paid", "支付完成");

    private String code;
    
    private String description;

    /**
     *
     * @param code
     * @param description
     */
    PayEvent(String code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     *
     * @param code
     * @return
     */
    public static PayEvent codeOf(String code) {
        for(PayEvent payEvent : PayEvent.values()) {
            if(StringUtils.equalsIgnoreCase(payEvent.getCode(), code)) {
                return payEvent;
            }
        }
        return null;
    }

    /**
     *
     * @return
     */
    public String getCode() {
        return this.code;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return this.description;
    }

    /**
     *
     * @return
     */
    public String getName() {
        return this.name();
    }

    /**
     *
     * @return
     */
    public int getOrdinal() {
        return this.ordinal();
    }
    
}
